import type { MemberAddress, MemberAddressParams, AddressQuery } from './types'
import { request } from '@/utils/request'

/* 获取地区列表 */
const baseUrl = '/api/user/address'
export const getRegionApi = () => {
	return request({
		url: baseUrl + '/region',
		method: 'GET',
	})
}
/* 收货地址列表 */
export const getMemberAddressListApi = (query : AddressQuery) => {
	return request<MemberAddress[]>({
		url: baseUrl + `/list`,
		method: 'GET',
		data: query
	})
}

/* 收货地址详情 */
export const getMemberAddressApi = (id : string | number) => {
	return request<MemberAddress>({
		url: baseUrl + `/${id}`,
		method: 'GET',
	})
}

/* 新增收货地址 */
export const addAddressApi = (data : MemberAddressParams) => {
	return request({
		url: baseUrl,
		method: 'POST',
		data
	})
}

/* 修改收货地址 */
export const updateAddressApi = (data : MemberAddressParams) => {
	return request({
		url: baseUrl,
		method: 'PUT',
		data
	})
}

/* 删除收货地址 */
export const delAddressApi = (id: string | number | Array<string | number>) => {
	return request({
		url: baseUrl+`/${id}`,
		method: 'DELETE',

	})
}